<?php
session_start();

$dbhost='localhost'; //country 0
    $dbuser='s91199'; //username 0
    $dbpass='123456'; //password 0
    $dbname='s91199'; //name 0
$conn=mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);

/*
$dbhost='localhost'; //country 0
    $dbuser='root'; //username 0
    $dbpass=''; //password 0
    $dbname='mydb'; //name 0*/
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
    $db = mysql_select_db($dbname,$conn);

$username = mysql_real_escape_string($_POST['user']);
$password1 = mysql_real_escape_string($_POST['password']);
$password=SHA1($password1);
$sql = "SELECT * FROM quanly WHERE admin_email='$username' AND admin_password ='$password'";
$result = mysql_query($sql) or die (mysql_error());

$count = mysql_num_rows($result);
$row = mysql_fetch_array($result, MYSQL_ASSOC);

if ($count==1){
        $_SESSION['admin_id']=$row['admin_id'];
        $_SESSION['admin_name']=$row['admin_name'];
        $_SESSION['message']="Hi admin, welcome back.";
        $_SESSION['admin_role']=$row['admin_role'];
        header("Location: adminhome.php");
 }  else{
    $_SESSION['message']="Invalid username or password. Please try again";
    header("Location: login.html");
}


?>